package com.itheima.job;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.OrderSettingService;
import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Calendar;

@Slf4j
public class ClearOrderSettingData {

    @Reference
    OrderSettingService orderSettingService;

    public void clearOrderSettingData() {
        log.debug("删除冗余预约设置数据的方法执行了");
        Calendar calendar = Calendar.getInstance();
        int today = calendar.get(Calendar.DAY_OF_MONTH);
        calendar.add(Calendar.DAY_OF_MONTH, -today);
        String date = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
        log.debug("要删除的日期断点" + date);
        Integer count = orderSettingService.deleteB4DataByDate(date);
        log.debug("删除了：" + count + "条数据");
    }
}
